﻿<?php
require_once('../db/check_login.php');
require_once('../db/config.php');
$db=new db($config);
$data=$db->getAll('artclass');
?>
<html>
<body>
<script type="text/javascript" charset="utf-8" src="../js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/ueditor/ueditor.all.js"> </script>
<script type="text/javascript">
   window.UEDITOR_HOME_URL = "..../js/ueditor/";
   UE.getEditor('content',{
        initialFrameWidth : 1050,
        initialFrameHeight: 300
    });
   var ue = UE.getEditor('content');
</script>
<form name="form1" method="post" action="">
<table width="100%" border="0">
  <tr>
    <td width="7%">标题:</td>
    <td width="93%"><label for="title"></label>
      <input type="text" name="title" id="title" size="60"></td>
  </tr>
  <tr>
    <td>类别</td>
    <td><label for="type"></label>
      <select name="type" id="type">
      <?php foreach($data as $val):?>
      <option value="<?php echo $val['id']?>"><?php echo $val['name']?></option>
      <?php endforeach;?>
      </select>
      </td>
  </tr>
  <tr>
    <td>内容:</td>
    <td>
     <script id="content" name="content" type="text/plain">
    </script>
	</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <input type="submit" name="sub" id="sub"  style=" width:80px; height:30px;" value="提交">
    </td>
  </tr>
</table>
</form>
</body>
</html>
<?php
if(isset($_POST['sub'])){
$title=$_POST['title'];
$type=$_POST['type'];
$content=$_POST['content'];
$subTime=date("Y-m-d H:i:s");
$insertData=array(
'title'=>$title,
'type'=>$type,
'content'=>$content,
'sub_time'=>$subTime
);
$row=$db->insert('article',$insertData);
if($row>0){
echo '<script type="text/javascript">alert("操作成功");location=("list.php");</script>';	
}
  }
?>
